Practical Perl Programming

Total Page:16

File Type:pdf, Size:1020Kb

Practical Perl Programming Practical Perl Programming A. D. Marshall 1999 HTML PERL NOTES ● Contents ● Introduction to Perl ❍ What is Perl? ■ Origins ■ Similar to C? ■ Cost and Licensing ❍ Installing Perl Installed ■ Getting and Installing Perl ❍ Writing Perl Programs ■ Creating the Program ■ Invocation ■ Comments in Your Program ❍ Further Reading/Information ● Numeric and String Literals ❍ Numeric Literals ■ Example: Numbers ❍ String Literals ■ Example: Single-Quoted Strings ■ Example: Double-Quoted Strings ■ Example: Back-Quoted Strings ● Variables ❍ Scalar Variables ■ Defining Scalar Variables ■ String Scalar Variables ● Arrays ❍ What is an Array? ❍ Literal Arrays ❍ Indexed Arrays ❍ Some Useful Array Functions ❍ Associative Arrays ■ Associative Array Operators ● Operators ❍ The Binary Arithmetic Operators ❍ The Unary Arithmetic Operators ❍ The Logical Operators ❍ The Bitwise Operators ■ Comparison operators for numbers and strings ❍ The Range Operator (..) ❍ The String Operators (. and x) ❍ Order of Precedence ● Perl Statements ❍ Understanding Expressions ❍ Statement Blocks ❍ Statement Blocks and Local Variables ❍ If/Unless statement ■ The for statement ■ The while/until statement ■ The foreach statement ● Functions ❍ Using the Parameter Array (@_) ❍ Passing Parameters by Reference ❍ Scope of Variables ❍ Using a List as a Function Parameter ❍ Nesting Function Calls ❍ Using a Private Function ❍ String Functions ❍ Array Functions ❍ Summary ● References ❍ Reference Types ❍ Passing Parameters to Functions ❍ The ref() Function ❍ Example: Creating a Data Record ❍ Interpolating Functions Inside Double-Quoted Strings ❍ Summary ● Files -- Input and Output in Perl ❍ Some Files Are Standard ■ Using the Diamond Operator (<>) ❍ File Test Operators ❍ File Functions ■ Reading Directories ■ Reading and Writing Files ■ Binary Files ■ Getting File Statistics ■ Printing Revisited ● Regular Expressions ❍ What are regular Expressions ❍ Using Regular Expressions ■ Special pattern matching character operators ❍ Backtracking ❍ Setting the Target Operator (Binding) ❍ Substitution ❍ The Matching Operator (m//) ■ The Matching Options ❍ The Translation Operator (tr///) ■ The Translation Options ❍ The Binding Operators ❍ Character Classes ❍ Quantifiers ❍ Pattern Memory ❍ Pattern Precedence ❍ Extension Syntax ❍ Pattern Examples ❍ Some Practical Examples ■ Using the Match Operator ■ Using the Substitution Operator ■ Example: Using the Translation Operator ■ Example: Using the Split() Function ● Reports ❍ Format Statements ❍ Field Lines ❍ Report Headings ● Special Variables ❍ What Are the Special Variables? ❍ Example: Using the DATA File Handle ❍ Example: Using the %ENV Variable ● Handling Errors and Signals ❍ Checking for Errors ❍ Using errno ❍ Using the || Logical Operator ❍ Using the die() Function ❍ Using the warn() Function ❍ Trapping Fatal Errors ■ Using the eval() Function ❍ Signals ■ How to Handle a Signal ● Objects in Perl ❍ What are objects? ❍ Classes ❍ Abtraction ❍ Polymorphism:Overriding Methods ❍ Encapsulation:Keeping Code and Data Together ❍ Objects in Perl ■ Bless the Hash and Pass the Reference ■ Initializing Properties ■ Using Named Parameters in Constructors ■ Inheritance: Perl Style ■ Polymorphism ■ One Class Can Contain Another ❍ Static Versus Regular Methods and Variables ● Perl Modules ❍ Module Constructors and Destructors ■ The BEGIN Block ■ The END Block ❍ Symbol Tables ❍ The require Compiler Directive ❍ The use Compiler Directive ❍ Pragma in Perl ❍ The strict Pragma ❍ The Standard Modules ❍ strict, my() and Modules ❍ Module Examples ■ The Carp Module ■ The English Module ■ The Env Module ● Debugging Perl ❍ Syntax Errors ❍ Common Syntax Errors ❍ Logic Errors ■ Using the -w Command-Line Option ■ Being Strict with Your Variables ■ Stepping Through Your Script ■ Displaying Information ■ Examples: Using the n Command ■ Using Breakpoints ■ Creating Command Aliases ■ Using the Debugger as an Interactive Interpreter ❍ Summary ● Perl Command-Line Options ❍ How Are the Options Specified? ❍ The Command-line Options ❍ Example uses of command-line options ■ Using the -0 Option ■ Using the -n and -p Options ■ Using the -i Option ■ Using the -s Option ❍ Summary ● Networking with Perl ❍ Sockets ❍ Clients and Servers ■ The Server Side of a Conversation ■ The Client Side of a Conversation ❍ Some Network Examples ■ Using the Time Service ■ Sending Mail (SMTP) ■ The MAIL Command ■ The RCPT Command ■ The DATA Command ■ Reporting Undeliverable Mail ■ Using Perl to Send Mail ❍ Receiving Mail (POP) ■ Checking for Upness (Echo) ❍ Transferring Files (FTP) ■ The World Wide Web (HTTP) ● CGI Programming in Perl ❍ CGI Scripting ■ What is a CGI Script? ■ Writing and Running CGI Scripts ■ Why Use Perl for CGI? ■ CGI Apps versus Java Applets ■ Should You Use CGI Modules? ❍ How Does CGI Work? ❍ Calling Your CGI Program ❍ Beginning CGI Programming in Perl ■ CGI Script Output ■ A First Perl CGI Script ■ Exectiion of CGI Programs ■ Why Are File Permissions Important in UNIX? ❍ HTTP Headers ■ CGI and Environment Variables ❍ URL Encoding ❍ Security ■ CGIwrap and Security ● The Other Side of CGI:Input -- HTML Forms ❍ A Brief Overview of HTML ❍ Server-Side Includes ❍ Forms: Facilitating User Input and Interaction ■ Forms and CGI: What are they? ■ Some Example Forms ■ The FORM Tag ■ Entering Data ■ The Submit Button ■ Text Input ■ Password ■ Associating labels with text and password input ■ Radio Buttons ■ Checkboxes ■ Assigning Initial Input Values to ■ Select ■ Textarea ■ Hidden Input ■ An Example Form ■ HTML Forms as an Interface to Databases ■ Further Information ❍ CGI Script Input: Accepting Input To Perl Scripts ■ Accepting Input from the Browser ■ Passing Data to a CGI Script ■ A Simple Form CGI Script Call ■ The Other Side -- receiving and processing information in CGI ( Perl) script ■ cgi-lib.pl ■ The cgi.pm module ■ A Minimal Form Response CGI Perl Script ■ Multiple argument input to a Perl CGI script ● Some Example Perl CGI Scripts ❍ Red, Green and Blue to Hexadecimal Converter ❍ An Address Book Search Engine ❍ Creating a Guest Book ❍ A Web Page Counter ● Using Perl with Web Servers ❍ Server Log Files ❍ Reading a Log File In Perl ❍ Listing Access by Document ❍ Looking at the Status Code ❍ Existing Log File Analyzing Programs ❍ Creating Your Own CGI Log File ● Internet Resources ❍ Web Sites ❍ Usenet Newsgroups ● A Quick Quide to HTML ❍ Basic HTML Programming ■ HTML ■ Hypertext Terminology ■ Creating HTML Documents ■ Learning HTML ■ Anatomy of Any HTML Document ■ HTML Tags ■ Basic HTML Page Structure ■ Summary of Basic HTML Tags ■ Bare-bones example of HTML ■ Basic HTML Coding ■ Head elements ■ The Body Element ■ Headings ■ Paragraphs ■ Comments ■ Links and Anchors ■ Linking to Other Documents ■ Relative, Absolute and remote Links ■ Anchors ■ Lists ■ Unordered or Bulleted lists ■ Ordered or Numbered lists ■ Glossary or Definition Lists ■ Nesting Lists ■ Preformatted Text ■ In-Line Images ■ External Images, Sounds, Video ■ Things to remember when HTML programming ❍ Text Formatting with HTML ■ Logical Character Formatting ■ Physical Character formatting ■ Special Characters ■ Horizontal rules and Line breaks ■ Fonts and Font Sizes ❍ Recommended Reading ● About this document ... next up previous Next: Introduction to Perl Up: Practical Perl Programming Previous: Practical Perl Programming Contents ● Contents ● Introduction to Perl ❍ What is Perl? ■ Origins ■ Similar to C? ■ Cost and Licensing ❍ Installing Perl Installed ■ Getting and Installing Perl ❍ Writing Perl Programs ■ Creating the Program ■ Invocation ■ Comments in Your Program ❍ Further Reading/Information ● Numeric and String Literals ❍ Numeric Literals ❍ String Literals ■ Example: Double-Quoted Strings ● Variables ❍ Scalar Variables ■ Defining Scalar Variables ■ String Scalar Variables ● Arrays ❍ What is an Array? ❍ Literal Arrays ❍ Indexed Arrays ❍ Some Useful Array Functions ❍ Associative Arrays ■ Associative Array Operators ● Operators ❍ The Binary Arithmetic Operators ❍ The Unary Arithmetic Operators ❍ The Logical Operators ❍ The Bitwise Operators ■ Comparison operators for numbers and strings ❍ The Range Operator (..) ❍ The String Operators (. and x) ❍ Order of Precedence ● Perl Statements ❍ Understanding Expressions ❍ Statement Blocks ❍ Statement Blocks and Local Variables ❍ If/Unless statement ■ The for statement ■ The while/until statement ■ The foreach statement ● Functions ❍ Using the Parameter Array (@_) ❍ Passing Parameters by Reference ❍ Scope of Variables ❍ Using a List as a Function Parameter ❍ Nesting Function Calls ❍ Using a Private Function ❍ String Functions ❍ Array Functions ❍ Summary ● References ❍ Reference Types ❍ Passing Parameters to Functions ❍ The ref() Function ❍ Example: Creating a Data Record ❍ Interpolating Functions Inside Double-Quoted Strings ❍ Summary ● Files -- Input and Output in Perl ❍ Some Files Are Standard ■ Using the Diamond Operator (<>) ❍ File Test Operators ❍ File Functions ■ Reading Directories ■ Reading and Writing Files ■ Binary Files ■ Getting File Statistics ■ Printing Revisited ● Regular Expressions ❍ What are regular Expressions ❍ Using Regular Expressions ■ Special pattern matching character operators ❍ Backtracking ❍ Setting the Target Operator (Binding) ❍ Substitution ❍ The Matching Operator (m//) ■ The Matching Options ❍ The Translation Operator (tr///) ■ The Translation Options ❍ The Binding Operators ❍ Character Classes ❍ Quantifiers ❍ Pattern Memory ❍ Pattern Precedence ❍ Extension Syntax ❍ Pattern Examples ❍ Some Practical Examples ■ Using the Match Operator ■ Using
Recommended publications
  • PRE PROCESSOR DIRECTIVES in –C LANGUAGE. 2401 – Course
    PRE PROCESSOR DIRECTIVES IN –C LANGUAGE. 2401 – Course Notes. 1 The C preprocessor is a macro processor that is used automatically by the C compiler to transform programmer defined programs before actual compilation takes place. It is called a macro processor because it allows the user to define macros, which are short abbreviations for longer constructs. This functionality allows for some very useful and practical tools to design our programs. To include header files(Header files are files with pre defined function definitions, user defined data types, declarations that can be included.) To include macro expansions. We can take random fragments of C code and abbreviate them into smaller definitions namely macros, and once they are defined and included via header files or directly onto the program itself it(the user defined definition) can be used everywhere in the program. In other words it works like a blank tile in the game scrabble, where if one player possesses a blank tile and uses it to state a particular letter for a given word he chose to play then that blank piece is used as that letter throughout the game. It is pretty similar to that rule. Special pre processing directives can be used to, include or exclude parts of the program according to various conditions. To sum up, preprocessing directives occurs before program compilation. So, it can be also be referred to as pre compiled fragments of code. Some possible actions are the inclusions of other files in the file being compiled, definitions of symbolic constants and macros and conditional compilation of program code and conditional execution of preprocessor directives.
    [Show full text]
  • Preview Objective-C Tutorial (PDF Version)
    Objective-C Objective-C About the Tutorial Objective-C is a general-purpose, object-oriented programming language that adds Smalltalk-style messaging to the C programming language. This is the main programming language used by Apple for the OS X and iOS operating systems and their respective APIs, Cocoa and Cocoa Touch. This reference will take you through simple and practical approach while learning Objective-C Programming language. Audience This reference has been prepared for the beginners to help them understand basic to advanced concepts related to Objective-C Programming languages. Prerequisites Before you start doing practice with various types of examples given in this reference, I'm making an assumption that you are already aware about what is a computer program, and what is a computer programming language? Copyright & Disclaimer © Copyright 2015 by Tutorials Point (I) Pvt. Ltd. All the content and graphics published in this e-book are the property of Tutorials Point (I) Pvt. Ltd. The user of this e-book can retain a copy for future reference but commercial use of this data is not allowed. Distribution or republishing any content or a part of the content of this e-book in any manner is also not allowed without written consent of the publisher. We strive to update the contents of our website and tutorials as timely and as precisely as possible, however, the contents may contain inaccuracies or errors. Tutorials Point (I) Pvt. Ltd. provides no guarantee regarding the accuracy, timeliness or completeness of our website or its contents including this tutorial. If you discover any errors on our website or in this tutorial, please notify us at [email protected] ii Objective-C Table of Contents About the Tutorial ..................................................................................................................................
    [Show full text]
  • C and C++ Preprocessor Directives #Include #Define Macros Inline
    MODULE 10 PREPROCESSOR DIRECTIVES My Training Period: hours Abilities ▪ Able to understand and use #include. ▪ Able to understand and use #define. ▪ Able to understand and use macros and inline functions. ▪ Able to understand and use the conditional compilation – #if, #endif, #ifdef, #else, #ifndef and #undef. ▪ Able to understand and use #error, #pragma, # and ## operators and #line. ▪ Able to display error messages during conditional compilation. ▪ Able to understand and use assertions. 10.1 Introduction - For C/C++ preprocessor, preprocessing occurs before a program is compiled. A complete process involved during the preprocessing, compiling and linking can be read in Module W. - Some possible actions are: ▪ Inclusion of other files in the file being compiled. ▪ Definition of symbolic constants and macros. ▪ Conditional compilation of program code or code segment. ▪ Conditional execution of preprocessor directives. - All preprocessor directives begin with #, and only white space characters may appear before a preprocessor directive on a line. 10.2 The #include Preprocessor Directive - The #include directive causes copy of a specified file to be included in place of the directive. The two forms of the #include directive are: //searches for header files and replaces this directive //with the entire contents of the header file here #include <header_file> - Or #include "header_file" e.g. #include <stdio.h> #include "myheader.h" - If the file name is enclosed in double quotes, the preprocessor searches in the same directory (local) as the source file being compiled for the file to be included, if not found then looks in the subdirectory associated with standard header files as specified using angle bracket. - This method is normally used to include user or programmer-defined header files.
    [Show full text]
  • Executable Code Is Not the Proper Subject of Copyright Law a Retrospective Criticism of Technical and Legal Naivete in the Apple V
    Executable Code is Not the Proper Subject of Copyright Law A retrospective criticism of technical and legal naivete in the Apple V. Franklin case Matthew M. Swann, Clark S. Turner, Ph.D., Department of Computer Science Cal Poly State University November 18, 2004 Abstract: Copyright was created by government for a purpose. Its purpose was to be an incentive to produce and disseminate new and useful knowledge to society. Source code is written to express its underlying ideas and is clearly included as a copyrightable artifact. However, since Apple v. Franklin, copyright has been extended to protect an opaque software executable that does not express its underlying ideas. Common commercial practice involves keeping the source code secret, hiding any innovative ideas expressed there, while copyrighting the executable, where the underlying ideas are not exposed. By examining copyright’s historical heritage we can determine whether software copyright for an opaque artifact upholds the bargain between authors and society as intended by our Founding Fathers. This paper first describes the origins of copyright, the nature of software, and the unique problems involved. It then determines whether current copyright protection for the opaque executable realizes the economic model underpinning copyright law. Having found the current legal interpretation insufficient to protect software without compromising its principles, we suggest new legislation which would respect the philosophy on which copyright in this nation was founded. Table of Contents INTRODUCTION................................................................................................. 1 THE ORIGIN OF COPYRIGHT ........................................................................... 1 The Idea is Born 1 A New Beginning 2 The Social Bargain 3 Copyright and the Constitution 4 THE BASICS OF SOFTWARE ..........................................................................
    [Show full text]
  • PHP Programming Cookbook I
    PHP Programming Cookbook i PHP Programming Cookbook PHP Programming Cookbook ii Contents 1 PHP Tutorial for Beginners 1 1.1 Introduction......................................................1 1.1.1 Where is PHP used?.............................................1 1.1.2 Why PHP?..................................................2 1.2 XAMPP Setup....................................................3 1.3 PHP Language Basics.................................................5 1.3.1 Escaping to PHP...............................................5 1.3.2 Commenting PHP..............................................5 1.3.3 Hello World..................................................6 1.3.4 Variables in PHP...............................................6 1.3.5 Conditional Statements in PHP........................................7 1.3.6 Loops in PHP.................................................8 1.4 PHP Arrays...................................................... 10 1.5 PHP Functions.................................................... 12 1.6 Connecting to a Database............................................... 14 1.6.1 Connecting to MySQL Databases...................................... 14 1.6.2 Connecting to MySQLi Databases (Procedurial).............................. 14 1.6.3 Connecting to MySQLi databases (Object-Oriented)............................ 15 1.6.4 Connecting to PDO Databases........................................ 15 1.7 PHP Form Handling................................................. 15 1.8 PHP Include & Require Statements.........................................
    [Show full text]
  • Operating System Engineering, Lecture 3
    6.828 2012 Lecture 3: O/S Organization plan: O/S organization processes isolation topic: overall o/s design what should the main components be? what should the interfaces look like? why have an o/s at all? why not just a library? then apps are free to use it, or not -- flexible some tiny O/Ss for embedded processors work this way key requirement: support multiple activities multiplexing isolation interaction helpful approach: abstract services rather than raw hardware file system, not raw disk TCP, not raw ethernet processes, not raw CPU/memory abstractions often ease multiplexing and interaction and more convenient and portable note: i'm going to focus on mainstream designs (xv6, Linux, &c) for *every* aspect, someone has done it a different way! example: exokernel and VMM does *not* abstract anything! xv6 has only a few abstractions / services processes (cpu, mem) I/O (file descriptors) file system i'm going to focus on xv6 processes today a process is a running program it has its own memory, share of CPU, FDs, parent, children, &c it uses system calls to interact outside itself to get at kernel services xv6 basic design here very traditional (UNIX/Linux/&c) xv6 user/kernel organization h/w, kernel, user kernel is a big program services: process, FS, net low-level: devices, VM all of kernel runs w/ full hardware privilege (very convenient) system calls switch between user and kernel 1 good: easy for sub-systems to cooperate (e.g. paging and file system) bad: interactions => complex, bugs are easy, no isolation within o/s called "monolithic";
    [Show full text]
  • Studying the Real World Today's Topics
    Studying the real world Today's topics Free and open source software (FOSS) What is it, who uses it, history Making the most of other people's software Learning from, using, and contributing Learning about your own system Using tools to understand software without source Free and open source software Access to source code Free = freedom to use, modify, copy Some potential benefits Can build for different platforms and needs Development driven by community Different perspectives and ideas More people looking at the code for bugs/security issues Structure Volunteers, sponsored by companies Generally anyone can propose ideas and submit code Different structures in charge of what features/code gets in Free and open source software Tons of FOSS out there Nearly everything on myth Desktop applications (Firefox, Chromium, LibreOffice) Programming tools (compilers, libraries, IDEs) Servers (Apache web server, MySQL) Many companies contribute to FOSS Android core Apple Darwin Microsoft .NET A brief history of FOSS 1960s: Software distributed with hardware Source included, users could fix bugs 1970s: Start of software licensing 1974: Software is copyrightable 1975: First license for UNIX sold 1980s: Popularity of closed-source software Software valued independent of hardware Richard Stallman Started the free software movement (1983) The GNU project GNU = GNU's Not Unix An operating system with unix-like interface GNU General Public License Free software: users have access to source, can modify and redistribute Must share modifications under same
    [Show full text]
  • Strings in C++
    Programming Abstractions C S 1 0 6 X Cynthia Lee Today’s Topics Introducing C++ from the Java Programmer’s Perspective . Absolute value example, continued › C++ strings and streams ADTs: Abstract Data Types . Introduction: What are ADTs? . Queen safety example › Grid data structure › Passing objects by reference • const reference parameters › Loop over “neighbors” in a grid Strings in C++ STRING LITERAL VS STRING CLASS CONCATENATION STRING CLASS METHODS 4 Using cout and strings int main(){ int n = absoluteValue(-5); string s = "|-5|"; s += " = "; • This prints |-5| = 5 cout << s << n << endl; • The + operator return 0; concatenates strings, } and += works in the way int absoluteValue(int n) { you’d expect. if (n<0){ n = -n; } return n; } 5 Using cout and strings int main(){ int n = absoluteValue(-5); But SURPRISE!…this one string s = "|-5|" + " = "; doesn’t work. cout << s << n << endl; return 0; } int absoluteValue(int n) { if (n<0){ n = -n; } return n; } C++ string objects and string literals . In this class, we will interact with two types of strings: › String literals are just hard-coded string values: • "hello!" "1234" "#nailedit" • They have no methods that do things for us • Think of them like integer literals: you can’t do "4.add(5);" //no › String objects are objects with lots of helpful methods and operators: • string s; • string piece = s.substr(0,3); • s.append(t); //or, equivalently: s+= t; String object member functions (3.2) Member function name Description s.append(str) add text to the end of a string s.compare(str) return
    [Show full text]
  • Declare Function Inside a Function Python
    Declare Function Inside A Function Python Transisthmian and praetorian Wye never ensphere helter-skelter when Shawn lord his nightshade. Larboard Hal rumors her dizziesacapnia very so encouragingly actinally. that Colbert aurifies very inferentially. Kenyan Tad reframes her botts so irefully that Etienne Closures prove to it efficient way something we took few functions in our code. Hope you have any mutable object. Calling Functions from Other Files Problem Solving with Python. What embassy your website look like? Then you can declare any result of a million developers have been loaded? The coach who asked this gas has marked it as solved. We focus group functions together can a Python module see modules and it this way lead our. What are Lambda Functions and How to Use Them? It working so art the result variable is only accessible inside the function in. Variables inside python node, learn more detail, regardless of instances of a program demonstrates it. The python function inside another, which start here, and beginners start out. Get code examples like python define a function within a function instantly right anytime your google search results with the Grepper Chrome. The function by replacing it contains one function start here are discussed: how do not provide extremely cost efficient as their name? How to the page helpful for case it requires you can declare python data science. Each item from the python function has arbitrary length arguments must first, but are only the output is simply the function to. We declare their perfomance varies with the gathered arguments using a wrapped the arguments does the computed fahrenheit to declare function inside a function python? List of python can declare a function inside a million other functions we declare function inside a function python.
    [Show full text]
  • Object-Oriented Programming Basics with Java
    Object-Oriented Programming Object-Oriented Programming Basics With Java In his keynote address to the 11th World Computer Congress in 1989, renowned computer scientist Donald Knuth said that one of the most important lessons he had learned from his years of experience is that software is hard to write! Computer scientists have struggled for decades to design new languages and techniques for writing software. Unfortunately, experience has shown that writing large systems is virtually impossible. Small programs seem to be no problem, but scaling to large systems with large programming teams can result in $100M projects that never work and are thrown out. The only solution seems to lie in writing small software units that communicate via well-defined interfaces and protocols like computer chips. The units must be small enough that one developer can understand them entirely and, perhaps most importantly, the units must be protected from interference by other units so that programmers can code the units in isolation. The object-oriented paradigm fits these guidelines as designers represent complete concepts or real world entities as objects with approved interfaces for use by other objects. Like the outer membrane of a biological cell, the interface hides the internal implementation of the object, thus, isolating the code from interference by other objects. For many tasks, object-oriented programming has proven to be a very successful paradigm. Interestingly, the first object-oriented language (called Simula, which had even more features than C++) was designed in the 1960's, but object-oriented programming has only come into fashion in the 1990's.
    [Show full text]
  • The Design of a Pascal Compiler Mohamed Sharaf, Devaun Mcfarland, Aspen Olmsted Part I
    The Design of A Pascal Compiler Mohamed Sharaf, Devaun McFarland, Aspen Olmsted Part I Mohamed Sharaf Introduction The Compiler is for the programming language PASCAL. The design decisions Concern the layout of program and data, syntax analyzer. The compiler is written in its own language. The compiler is intended for the CDC 6000 computer family. CDC 6000 is a family of mainframe computer manufactured by Control Data Corporation in the 1960s. It consisted of CDC 6400, CDC 6500, CDC 6600 and CDC 6700 computers, which all were extremely rapid and efficient for their time. It had a distributed architecture and was a reduced instruction set (RISC) machine many years before such a term was invented. Pascal Language Imperative Computer Programming Language, developed in 1971 by Niklaus Wirth. The primary unit in Pascal is the procedure. Each procedure is represented by a data segment and the program/code segment. The two segments are disjoint. Compiling Programs: Basic View Machine Pascal languag program Pascal e compile program filename . inpu r gp output a.out p t c Representation of Data Compute all the addresses at compile time to optimize certain index calculation. Entire variables always are assigned at least one full PSU “Physical Storage Unit” i.e CDC6000 has ‘wordlength’ of 60 bits. Scalar types Array types the first term is computed by the compiler w=a+(i-l)*s Record types: reside only within one PSU if it is represented as packed. If it is not packed its size will be the size of the largest possible variant. Data types … Powerset types The set operations of PASCAL are realized by the conventional bit-parallel logical instructions ‘and ‘ for intersection, ‘or’ for union File types The data transfer between the main store buffer and the secondary store is performed by a Peripheral Processor (PP).
    [Show full text]
  • Learning Perl Through Examples Part 2 L1110@BUMC 2/22/2017
    www.perl.org Learning Perl Through Examples Part 2 L1110@BUMC 2/22/2017 Yun Shen, Programmer Analyst [email protected] IS&T Research Computing Services Spring 2017 Tutorial Resource Before we start, please take a note - all the codes and www.perl.org supporting documents are accessible through: • http://rcs.bu.edu/examples/perl/tutorials/ Yun Shen, Programmer Analyst [email protected] IS&T Research Computing Services Spring 2017 Sign In Sheet We prepared sign-in sheet for each one to sign www.perl.org We do this for internal management and quality control So please SIGN IN if you haven’t done so Yun Shen, Programmer Analyst [email protected] IS&T Research Computing Services Spring 2017 Evaluation One last piece of information before we start: www.perl.org • DON’T FORGET TO GO TO: • http://rcs.bu.edu/survey/tutorial_evaluation.html Leave your feedback for this tutorial (both good and bad as long as it is honest are welcome. Thank you) Yun Shen, Programmer Analyst [email protected] IS&T Research Computing Services Spring 2017 Today’s Topic • Basics on creating your code www.perl.org • About Today’s Example • Learn Through Example 1 – fanconi_example_io.pl • Learn Through Example 2 – fanconi_example_str_process.pl • Learn Through Example 3 – fanconi_example_gene_anno.pl • Extra Examples (if time permit) Yun Shen, Programmer Analyst [email protected] IS&T Research Computing Services Spring 2017 www.perl.org Basics on creating your code How to combine specs, tools, modules and knowledge. Yun Shen, Programmer Analyst [email protected] IS&T Research Computing
    [Show full text]